package com.zx.idc.backend.gui.scheduler.slog.accesslog;

import com.zx.idc.ds.httplog.service.IHttpLogAccessLogService;
import com.zx.idc.ds.sys.entity.SysConfiguration;
import com.zx.idc.ds.sys.service.ISysConfigurationService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

public class AccessLogScheduledJob implements Job {

    @Autowired
    private IHttpLogAccessLogService accessLogService;
    @Autowired
    private ISysConfigurationService iSysConfigurationService;


    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        SysConfiguration sysConfiguration=iSysConfigurationService.selectOne(new SysConfiguration().setConfigKey("sysSettings_retain_visitlog_day"));
        Integer configValue=Integer.parseInt(sysConfiguration.getConfigValue());
        if(configValue>0){
            accessLogService.deleteByTime(configValue);
        }
    }
}
